package com.pet.petadoption.pet.biz.petBizImpl;

import com.pet.petadoption.pet.biz.PetBiz;
import com.pet.petadoption.pet.entity.Pet;
import com.pet.petadoption.pet.mapper.PetMapper;
import com.sun.org.apache.bcel.internal.generic.RETURN;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class PetBizImpl implements PetBiz {
//    @Autowired
    @Resource
    PetMapper petMapper;


    @Override
    public List<Pet> getAllPet(Integer index,Integer size) {
        //        计算上一页最后一条数据
        int newIndex = (index-1)*size;
        Map<String,Object> map = new HashMap<>();
        map.put("index" ,newIndex);
        map.put("size",size);
        return petMapper.getAllPet(map);
    }

    @Override
    public List<Pet> getAllPetNotAdopted(Integer index,Integer size) {
        //        计算上一页最后一条数据
        int newIndex = (index-1)*size;
        Map<String,Object> map = new HashMap<>();
        map.put("index" ,newIndex);
        map.put("size",size);
        return petMapper.getAllPet(map);
    }

    @Override
    public Pet findPetById(Integer id) {
        return petMapper.findPetById(id);
    }

    @Override
    public List<Pet> findPetByInfo(String info) {
        return petMapper.findPetByInfo(info);
    }

    @Override
    public Boolean addPet(Pet pet) {
        return petMapper.addPet(pet);
    }

    @Override
    public Integer delPet(Integer id) {
        return petMapper.delPet(id);
    }

    @Override
    public Integer modifyPet(Pet pet) {
        return petMapper.modifyPet(pet);
    }

    @Override
    public Integer delArr(String ids) {
        return petMapper.delArr(ids);
    }
}
